adding trhread safe matplotlib + json handling