refactor code to allow for configuration