Implements score calculation