flip function works
better naming, comments, and formatting