main part implemented