introduced new function for calculating response