minor modifications suggested by LucPerkins