fixed bug in scoring function
js version with viewer