array added, functions changed to work