removed code duplication
added button to open panel