Refactor Code

Clear code and eliminate repeat