started over with functions to learn better