This is weird. You have a real boolean here, while the code uses 1 and 0 just above