When I take the if statement out it works but it deletes the title as well