Introduced threading to increase performance