Added a quick workaround for scans containing nan values. However,
this is an inefficient approach which has to be replaced.