Origin of the phase change from pyrochlore to perovskite-like layered structure and a new lead free ferroelectric