Code tidying suggested by Mark Wotton