finished most functionality minus the repeat functionality