Refactored code for data availability on sample edit page