cleaned up stat data code