Move retrieval of lock inside the respond function.