added comments, used methods in a few places