calling new inside a class method