Fixed NoneType if statement