fixed coding errors in command handling code