Fix calculate total bug