working on moving the functions to testable code