works much better, with better debugging :)