corrected set_source function