Fixing some function return code