moved test to prevent dumb error
implemented helper function