Restructred some codes