creadted lib and funcitons for separated thread