stack completed with dynamic memory allocation