Bug fixing and comments added