added attach function