added synchronized lock to secure db