fix change of lock inside writelock