refactoring to go with a procedural approach