move try except to main