adding lock for connection