Modified as per Davids instructions