fix style and refactor