more changes to abstract the code