Code rewrite and one more feature added