need to check for null, otherwise it will throw error on first run when using instance mode