the best thing to do when Your boat capsizes but remains afloat is: Hang onto the boat or climb onto it.
When this happen, the best bet that you have is to stand on the remains as a lifeline and wave your hands to help the rescuers or passing boats locate you. Tried to swim away from it will be very reckless because it will be very likely that you do not know the distance between you and the shore.