added multiple data structures and wrapped in function