check rectangle and find upper position