addgin if statement to avoid crashes