Updated code to explicitly check if the value if true/false not just if it exits