file handling should be external to this method