Restructured scoring code