Fix console errors regarding undefined values