fixed code style and refactoring