Switched to dynamic memory allocation