Adding an if check for API