Updated to work with 4.0+