added bonds, cleaned up code