add switch for working out return type.
Merge remote-tracking branch 'origin/master'