move logic from factory into view