changed em to use vector instead of allocating arrays on stack