multiple changes, added code for group statistics
made some changes