throwing error if locking fails