Fix bool casting function