move some helper methods to models