adding some error handling and background job processing