modifying the code to work