A method comprising: measuring a set of energy level values for a multi-level system which includes first and second working levels |0>, |1> which provide a qubit and N-1 non-working levels including non-working level |2> , wherein N is a positive integer greater than or equal to 10; and performing an iteration at least once comprising: determining quantum leakage from at least one of the first and second working levels to the non-working levels for an n th estimate of a quantum operation A comprising a set of one or more pulses including a pulse having a given pulse duration, wherein n ≥ 1, and wherein determining the quantum leakage comprises determining: α i = ∑ j ≠ 0,1 N C ij 2 where α i is quantum leakage for a working level labelled by i , where i is equal to 0 or 1, j is a label for all available levels, and C ij is a complex coefficient for a non-working level; determining whether the quantum leakage is greater than or equal to a threshold value; in dependence of the quantum leakage being greater than or equal to the threshold value, changing the duration of at least one of the at least one pulse to form an (n+1) th estimate of the quantum operation A; and applying a sequence of electric potential pulses including the at least one of the at least one pulse having the changed duration to the qubit; repeating the iteration for the (n+i) th estimate of the quantum operation A. measuring a set of energy level values for a multi-level system which includes first and second working levels |0>, |1> which provide a qubit and N-1 non-working levels including non-working level |2> , wherein N is a positive integer greater than or equal to 10; and performing an iteration at least once comprising: determining quantum leakage from at least one of the first and second working levels to the non-working levels for an n th estimate of a quantum operation A comprising a set of one or more pulses including a pulse having a given pulse duration, wherein n ≥ 1, and wherein determining the quantum leakage comprises determining: α i = ∑ j ≠ 0,1 N C ij 2 where α i is quantum leakage for a working level labelled by i , where i is equal to 0 or 1, j is a label for all available levels, and C ij is a complex coefficient for a non-working level; determining whether the quantum leakage is greater than or equal to a threshold value; in dependence of the quantum leakage being greater than or equal to the threshold value, changing the duration of at least one of the at least one pulse to form an (n+1) th estimate of the quantum operation A; and applying a sequence of electric potential pulses including the at least one of the at least one pulse having the changed duration to the qubit; determining quantum leakage from at least one of the first and second working levels to the non-working levels for an n th estimate of a quantum operation A comprising a set of one or more pulses including a pulse having a given pulse duration, wherein n ≥ 1, and wherein determining the quantum leakage comprises determining: α i = ∑ j ≠ 0,1 N C ij 2 where α i is quantum leakage for a working level labelled by i , where i is equal to 0 or 1, j is a label for all available levels, and C ij is a complex coefficient for a non-working level; determining whether the quantum leakage is greater than or equal to a threshold value; in dependence of the quantum leakage being greater than or equal to the threshold value, changing the duration of at least one of the at least one pulse to form an (n+1) th estimate of the quantum operation A; and applying a sequence of electric potential pulses including the at least one of the at least one pulse having the changed duration to the qubit; repeating the iteration for the (n+i) th estimate of the quantum operation A. <EOS>