Added a height check on line 22 to prevent outofbounds