the main functionality