bundle bug fix and refactor optimizing