code refectored