Fixed and finished command code