Changed some code to deal with arrays in handlers