code tidyup
more code abstraction
more code tidyup