made some minor changes, implemented timeout for registration