replaced forloops with switch replace