Fixing the return value bugs