Forgot to nest some code in an if statement