done some code refactoring