Added debug and attempted to correct logic for rendering