working on lee algorithm