code refactor, increase modularity