speeded up some functions