fixed errors, removed redundancy