Pregunta de entrevista de Ribbon Home

refactor this code in the best way possible.