Got rid of deep else-ifing