minor improvements to the code