Refactored version with Bill's files