light refactor
further refactor for extensibility