finished survey code - first revision