code cleanup

code clean-up & made code stable