cleanup refactor code