Updated code to work with new structure