improved return value handling