corrected severl issue revealed by testing