allocation code separated and working