adapted code for other stats, should work now