just a remark, it's not for this patch, but this function is so tedious :( I'd love to use the Template library instead of this ;)