refactor code for reuse and passing the build