change bool_to_int to use ternary operator