fixed output and exit handler