add rect logic