fix to avoid crashes