Refactored building code