bugfix in mid string manipulation