Fixed out of range checks