Min code for main function JS