Added SQL clause groupBy to enhance performance
Added comments