refactoring, added handler func