improvments and small array bug