merged backend Gallery Model code