finished first six functions