Fixed out of range problem