modified function code