fixing model SQL