some code refectoring