implemented get_stack_grow_direction algorithm