working on pan function