Added logic for models