cleaning up code to remove redundancy