its working. But slow (coz of printfs)