Building function to match requires to variables