refactor function package ans type conversion via context