the whole code -- frist time