slightly refactor pendulum for dimension handling