got rid of temporary array