improved handling of methods (still needs refactoring)