big refactor

big refactor