large refactor and started to consider hashtables