refactor of photmolistener