return error value correctly