added size logic, untested in production