Not the cleanest but did the job