finished except for the optimize