REFACTOR to make it modular