finally got the calculate working