tweaked rectangle code to make it less horrendously ugly