Added little changes to make it work in baley