Array gets emptied if modified in function [4537]