Works most of the time, but sometimes it makes out-of-bounds or something like that