replaced elseif checks with separate ifs