make variables defined when needed, fixes #9