both codes almost finished