code refactor and new structure