move code into helpers