Pergunta de entrevista da empresa Tray.ai

Refactor this code in a readable and future-prone way