main functionality complete