added helper javascript method to split arrays