added better check of return