error logging to DB, fixed bug