added better coord detection