remove the huge blob of if/else