refactoring, moving into functions
Merge pull request #1 from SteveStedman/refactoring

refactoring, moving into functions