refactored immutability implementation