removed redundancies in code