Improved theory for calculating sap flow with the heat pulse method