made some changes to make it all work