Fixing database lock exception