Utilize exit command and make logic more readable