Optimized database interface
Added cancellation for user
Added error handling