Trade machine fix

Fix to a possible null pointer