cleaned up comments, added exit status, expanded case expressions