change some lines
merge two implementations