cleaning up stats code