added functions for source target calculations.