added synchronized to the methods that do data access