code refactored to use the new schema