add id generator, simple refactor