implement input switching and integrate modularity measure