lot of refactor