added code to choose source type