main: refactor