change the type of arguments from list to array for efficiency