moved some logic to helper module