fixed incorrect usage of $each