Added arguments to thread fucnctions