Completed tiles code, not optimised for hacker inputs