refact codes