fixed arrayexp and added more error handling