added empty array check for save