Updated code for better javascript api usage. array.filter().