cleaning up some code and updating community detection process