cleanup nearly finished, need to define a function