Added support for multi threading