revised and added more documentation comments