Fix removing elements from array