finished refactoring and added error checking for strings read from file