add detach and attach methods for substates