Refactor bag bugfix