found good data structure and implemented important functions