worked out the bug