Fix bug with logic being wrong way around