add some functions according to rails tutorial