refactor and introduce module structure