changed and redefined names and cleaned code