Started on answer for 23 but needs refactor for optomization