use as library improve error handling publish crate