modified lib for issue #178