integrated function to deal  with inputs