added preliminary score counting, fixed potential bug