merged pull req #12 and #17