fixed problem that was caused if ngal==1