using function instead of instance variable

Resolves #20