with some minor bug