bug fixed; handle exceptions within getNextUid