adding balance and agent functions
Added full functionality from android port