Finally updated the code