better error handling and idempotency for shell changing