improved tile placement logic