prevent String out of bounds exception