Fix package errors, make the code more elegant
Bug fixing