re-arranging code