Genralised the code