First version of the main script