adding in function to work with file handler, abstract out commonalities