refactor code to remove unnecessary code