fix bugs
first version done , ready for OJ