fixed getting rect coordinates function