changed char comparision to use '\0' as unitialized value