tidy up and pass actual values to a function instead of an array