Improved the addPanel

todo: fix the MVC pattern