Added predictions and cleaned up the code