updated with CursorIndexOutOfBoundsException error