Refactor according to Simon's suggestion