added gems system update and clean up to the update function