Fixes #13 by moving common code to the helper