some bug fix and glue together