more robust command dispatch using 'type -t'