updated to return -1 when the command fails