Added Registration and restructured code