fixed some bugs

ok now the command should generate correct output. i recommend a total refactoring of this command btw ;)