refactor to packages

Refactor to packages