fixed some more potential bugs