Move string type check to helper function