refacotr code structure