made bad exit flag 1 instead of -1