refactored and crudded new implementation