Modified record saving to prevent duplicate records in mongodb