updated to work for more than one