Modified to make sure that it always set a default value of 1 or 0 in the query.