Refactored the build method