Fixed out of bound issues