A bill that would bar Massachusetts drivers from using handheld cellphones behind the wheel is inching closer to final approval by state lawmakers.

A compromise version of the bill was released Monday. The Massachusetts House and Senate had approved separate versions.

The bill would prohibit drivers from holding cellphones while driving, but it would allow hands-free cellphones. Massachusetts already bans texting while driving.

The bill would impose fines of $100 for a first offense, $250 for a second offense and $500 for a subsequent offense.

The bill requires the Registry of Motor Vehicles to collect data from every traffic citation, including the age, race and gender of the driver, without identifying the driver.

The information would help identify law enforcement agencies that may be engaging in racial or gender profiling.