The function's return-type is int, not bool; so this should return 0, or perhaps -1 (as it's indicative of error), not false !  Likewise several cases below.