added library and sample function including tests