updated code works like top execution