adjusted to work as lib