rewrote chain scoring function for better performance and more obvious behavior