Cleaning up the code. Added a comment on top.