Fix bug were handler function was only kept as a reference and not copied