imported hacked version
added middleware