Improved structure of script.