add exit and function