writed main part of code