adding lock to make sure connection is up.