adapted code to powerlib