Fixed code to run on cluster