A new approach to the correlation functions of W-algebras