implemented main functionality