Converted scale from function to generator