fixing bugs revealed by testing