partial code refactoring