fix algorithm with camera offsets