simplified new code & added isUsingPanel()