add locking and support it wherever needed