Cleaning up this logic.