Viagogo interview question

refactor a poorly written code segment