functional version of registration script v2