almost implemented the first part