some flaws fixed