Much cleaner solution as in this case the logic stays in this file