use logicals instead of 1 and 0