Added comments and updated if statements.