Add field checks to prevent from undefined index errors