Modified the algorithm to use virtual top and bottom sites
Adding tests