some bug fixed, comments added