changed function to accept array