moved helper functions to __init__