copied over the changes Jon made and made some changes myself