Modified and updated code