more rafactoring on code