use local vars and quotes
use errno module and raise exception if bad command received
fix errno bug, use variables for range exception string