addresses the first comment and cleans up the code