refactored parsedsn function