properly detect return type when detecting function type