making use of locks optional by adding instance variable