resolved unexpected return in Ajax function