improve error message in bind_function