Added comments and eliminated a redundant "else" statement