Working on getting this function. Refactoring