Modified the getTitles function