Fix argument out of range error