how does a pendulum clock work