new version per programmingpraxis's suggestion