new implementation, with tests, parameters done
d