The openPanel function is duplicate code.