Added error handling
Added classes and DB