ref buttons working without proper ordering
sort order bugfix
refactoring
refactoring