made tile placing algorithm less redundant