updated: added error support and custom object support