some minor bug fixed. formatted code