Create mainfct