cleaned up code, use more efficient hashtable over list