submitted adapted code