seperate function for input stream detection