improved sender function