Refactor code and modify style