added comments and removed unnecessary functions