improve code, psr2 and implements log request and response