added comments and removed unused lines of code