added an if statement that was necessary