add common function to help process the input