optimize crazy string manip
optimize another crazy string manip