finished prime function