better error handling
fixed errors with empty objects