Refactored topological indices so that it finally works