Upating: reorganizing some code