make columns and count configurable, and refactory the code