Fix out of range error when getting command