completed entire first function