Fix bug in deactivate