added static factory method, should fix #4 and #5