Refactor of wall code