Updated code for managing