adds second error check on if statement