corrected some inefficiencies in calls to strlen() in loop structures