implemented lastIndexOf and some other functions