bug fixes, and added procedure to get balance