unfinished refactoring
more flexible design