change style and refactor code