Repaired input_to function