slight refactoring, convert ifs to else ifs