update Yashar's code