move duplicate getStringWidth method to seperate class