adding stat gathering function