Changed function with new structure