main functionality finished