reorganizing code
changed arguments order