removed some logging and added some array checks