localize brick's state and introduce immutability to simplify the implementation