Fixed boolean check, tidied a bit