added init function and #82 fix