Function modification

Bug detected - possible fix found.