Removed redundancies in code