changed registration function so it writes in database