added function 'add_label()' and modified 'write_master()' to utilize it.