adapted code to given parameter data structure