Error handling and query params preparations