add functions to panel and fix bugs in panel