Updated script to use return instead of exit