cAdapted to newest libs