pop array element only when its empty