Updated according to the new API