refactored code for creation of ledges