improved shell handling