create_object middleware restructured