[RK] code refactoring