replaced the 'if key == 'r' then statements with a switch(key) {case ('r'): foo; break; case('g'): bar; break; ,,,}