1) replace bool return type to int return type. seems to be causing some unexpected behaviour from gcc compiler