Modularized and Refactored readInput