refactor code to remove unneeded code