Added some commenting. Created 2 methods (writeData(), loadData()) to clean up the switch statement.