Got rid of unnecessary code. Added comments.