normalize function/method context & refactoring