getString function rearraged