Refactor; shouldn't have written this at 6am