tweaking the code to be nicer