Code formatting and Bug fixing