added comments and removed garbage code