old, semi-working code (without stat weight)