cleaning up the input processing which has become rather cluttered