Fix buggy behaviour of the on method.