slow but working version :)