modified exitnow to take in optional return value