data prep function to simplify scripting