Hopefully fixed undefined indexes errors