minor refactor to Function
added Thread class