sum is now dynimically calculated according to xst, yst