added better mouse down algoritm