fixed issue with fn() being called multiple times