MAIN FUNCTION