Removed use of alloca (considered bad practice due to possible undetected stack overflow)