cleaned up code, removed redundancy