fixes bug in cmd calculation