Re write most of read_cmd