update subroutines, add grep to filter the array