code almost finished