added else if instead of multiple ifs