fixed issue 24

#24 issue 24 caused by get element by slicing
to avoid out of bound
Use catch indexError instead