some code restructions