modified code to be adjust with new changes