function refund() {
        if (!has_presale_time_ended()) throw;
        if (is_min_goal_reached()) throw;
        if (block.number > refund_window_end_block) throw;
        
        var amount = balances[msg.sender];
        
        if (amount == 0) throw;
        
        
        balances[msg.sender] = 0;
        
        
        if (!msg.sender.send(amount)) throw;
    }