Making some of the logic more readable