Check cmd before using it

Fixes #48