cleaned out the code to remove redundancies