fixed bounds checking
made use of getTileAt, which I should have been doing in the first place