add logging and escaping