code for calculating scores