move textLayer creation to function and make textLayer permanent