add exception guard to db operation