a few changes to the code