started to change to new code design
unfinished and contains error