fixed some errors, added comments and ending lines