refact code