rest of the code for main.as