further refactor
further refactor and modularisation