added most of old functionality