Fixed bug in return value checking functions