Updated allocation tasks to stay inside a single function