Refactor code and fix bug with group order