added magic fields middleware