refactored method to remove unneccessary if/else statements