changed distance calculation to RGB space