compiles.. needs a rewrite..
once again compiles.. algorithm is closer..