a slow, but relatively clear solution