Pull out input handling to private methods.