refactoring
inlining those functions