big bidlocode. Refactoring will be tomorrow