Pregunta de entrevista de Tray.ai

Refactor this code in a readable and future-prone way