updated the code to latest working head