Added proper math for inner and outer edges (independent of each other