Tidying up some of the logic. Should rip out the threshold to an option