further attempts to refactor