could this be made into one if/else, rather than three if-ends?