Working version with OWIN middleware