improved return value handling and unified output