updating the code to make it work