Fixed username writing to database