Minor changes; added function