Fixed logic to test if panel removal is necessary