Fixes minor bug on function return code