Adapted code for the better interface