revised an over-engineered solution