Why does not the function return property of the object?