added modification functionality, reworked code flow