refactoring ... but not totally clean