multiple changes

- corrected #else statement in the end
- added default case for invalid mode specifiers
Added a few checks for invalid input