Renamed temp to free var for use as array index
Started using trie for indexes