Fixed and improved get function