added find substring function since strcasestr is not portable