changed to edge issue #12 + fixed some bugs