did some code refactoring