added some useful functions and fixed comments