moved from BB and refactored