Added more logic to the command parser loop.