Move logic from views to helpers