fixed some potential errors