reorganaize code