* further improvements to memory and cpu usage
* this version is bugged. it does not return the minimum but somethin nearly minimal