refactored getset function