fix wrong function context. Fixes #421