add support for query parameters
simplify code