Rewritten function for Result calc
Save Work. To-DO change Test Line 177
works without precendenz