try to rewrite generate_sid method

try to rewrite generate_sid method