main functionality implementation