made some changes to add function