refactoring from functions into class methods