First revision
fix bugs