bug fixed. Output changed. Comments added