pretty code and bug fixed.