Fixed ORM logic