Adapted it to suit the new defines