selectBy() updated to handle arrays