ADDED comments and simplified code