Fix buggy behaviour onmouseup