Found a much better method for dealing with the return types of invoked functions.