fixed last index bug for get method