Convert boolean to integer properly