moved method to helper, added tests, cleanup