inline function and change some organisation of code