refactor code and add normalize