better grouping algorithm and better project structure