Replaced many ifs with one switch