Changed rect.right to rect.top